<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<style type="text/css">
    input[type="checkbox"], input[type="radio"] {
    cursor: pointer;
    height: 18px;
    left: -9999px;
    opacity: 1;
    position: static;
    width: 18px;
    z-index: 12;
}
</style>
<!-- Page Content -->
    <div class="page-content">
        <!-- Page Breadcrumb -->
        <div class="page-breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a href="#">首页</a>
                </li>
                <li class="active">
                    <a href="#">角色管理</a>
                </li>
            </ul>
        </div>
        <!-- Page Body -->
        <div class="page-body">
            <div class="row">
                <div class="col-xs-12 col-md-12">
                    <div class="tab-content tabs-flat no-padding">
                        <div id="visits" class="tab-pane active animated fadeInUp">
                                <div class="row">
                                    <form  action="/luckydog/role/SystemPowerSet" method="POST" id="theForm"  target="_parent" style="padding:20px; 20px;" >
                                    <input type="text" name="rolename" placeholder="角色名称" value="<?php echo $name;?>" />
                                            <table width="90%"  height="30" border="0" cellpadding=0 cellspacing=0  class="table-bordered table-invoice SystemlRoot">
                                            <tr>
                                                <td  width="140px" valign='middle' class='title_td' style="display:none">
                                                    <input type="checkbox" class="title"  name="System" class="title" id="System"<?php if($powerInfo['System']['SystemManager']):?>checked="checked" <?php endif;?> style="opacity: 0;" >系统管理
                                                </td>
                                                <td span="2">
                                                    <table width="90%"   cellpadding=0 cellspacing=0 class="noborder"  >
                                                        <tr>
                                                            <td height="26" valign="center"  rowspan="2"  class="System_next" >
                                                                <input type="checkbox" name="SystemManager" <?php if($powerInfo['System']['SystemManager']):?>checked="checked" <?php endif;?>  >系统管理
                                                            </td>
                                                            <td class="actClass"><input type="checkbox" name="SystemManagerRole"  class="SystemManager_next" <?php if(in_array('SystemManagerRole',$powerInfo['System']['SystemManager'])):?>checked="checked" <?php endif;?> >角色管理</td>
                                                        </tr>
                                                        <tr><td class="actClass"><input type="checkbox" name="SystemManagerAccount"class="SystemManager_next" <?php if(in_array('SystemManagerAccount',$powerInfo['System']['SystemManager'])):?>checked="checked" <?php endif;?> >账号管理</td></tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>

                                        <table width="90%"  height="30" border="0" cellpadding=0 cellspacing=0  class="table-bordered table-invoice UserRoot">
                                            <tr>
                                                <td width="140px" valign='middle' class='title_td' style="display:none">
                                                    <input type="checkbox" class="title"  name="User" class="title" id="User"<?php if($powerInfo['User']['UserManager']):?>checked="checked" <?php endif;?> style="opacity: 0;" >用户管理
                                                </td>
                                                <td>
                                                    <table width="90%"   cellpadding=0 cellspacing=0 class="noborder"  >
                                                        <tr>
                                                            <td height="26" valign="center"  rowspan="2" scope="col" class="User_next" >
                                                                <input type="checkbox" name="UserManager" <?php if($powerInfo['User']['UserManager']):?>checked="checked" <?php endif;?>  >用户管理
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td class="actClass"><input type="checkbox" name="UserManagerUser"class="UserManager_next" <?php if(in_array('UserManagerUser',$powerInfo['User']['UserManager'])):?>checked="checked" <?php endif;?> >用戶列表</td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>

                                        <table width="90%"  height="30" border="0" cellpadding=0 cellspacing=0  class="table-bordered table-invoice ZixunRoot">
                                            <tr>
                                                <td width="140px" valign='middle' class='title_td' style="display:none">
                                                    <input type="checkbox" class="title"  name="Zixun" class="title" id="Zixun"<?php if($powerInfo['Zixun']['ZixunManager']):?>checked="checked" <?php endif;?> style="opacity: 0;" >资讯管理
                                                </td>
                                                <td>
                                                    <table width="90%"   cellpadding=0 cellspacing=0 class="noborder"  >
                                                        <tr>
                                                            <td height="26" valign="center"  rowspan="2" scope="col" class="Zixun_next" >
                                                                <input type="checkbox" name="ZixunManager" <?php if($powerInfo['Zixun']['ZixunManager']):?>checked="checked" <?php endif;?>  >资讯管理
                                                            </td>
                                                            <td class="actClass"><input type="checkbox" name="ZixunManagerNews"  class="ZixunManager_next" <?php if(in_array('ZixunManagerNews',$powerInfo['Zixun']['ZixunManager'])):?>checked="checked" <?php endif;?> >新闻管理</td>
                                                        </tr>
                                                        <tr><td class="actClass"><input type="checkbox" name="ZixunManagerMessage"class="ZixunManager_next" <?php if(in_array('ZixunManagerMessage',$powerInfo['Zixun']['ZixunManager'])):?>checked="checked" <?php endif;?> >消息管理</td></tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>

                                        <table width="90%"  height="30" border="0" cellpadding=0 cellspacing=0  class="table-bordered table-invoice ZiyuanRoot">
                                            <tr>
                                                <td width="140px" valign='middle' class='title_td' style="display:none">
                                                    <input type="checkbox" class="title"  name="Ziyuan" class="title" id="Ziyuan"<?php if($powerInfo['Ziyuan']['ZiyuanManager']):?>checked="checked" <?php endif;?> style="opacity: 0;" >资源管理
                                                </td>
                                                <td>
                                                    <table width="90%"   cellpadding=0 cellspacing=0 class="noborder"  >
                                                        <tr>
                                                            <td height="26" valign="center"  rowspan="2" scope="col" class="Ziyuan_next" >
                                                                <input type="checkbox" name="ZiyuanManager" <?php if($powerInfo['Ziyuan']['ZiyuanManager']):?>checked="checked" <?php endif;?>  >资源管理
                                                            </td>
                                                            <td class="actClass"><input type="checkbox" name="ZiyuanManagerLeibie"  class="ZiyuanManager_next" <?php if(in_array('ZiyuanManagerLeibie',$powerInfo['Ziyuan']['ZiyuanManager'])):?>checked="checked" <?php endif;?> >类别设计</td>
                                                            <td class="actClass"><input type="checkbox" name="ZiyuanManagerKejian"class="ZiyuanManager_next" <?php if(in_array('ZiyuanManagerKejian',$powerInfo['Ziyuan']['ZiyuanManager'])):?>checked="checked" <?php endif;?> >课件管理</td>
                                                        </tr>
                                                        <tr>
                                                            <td class="actClass"><input type="checkbox" name="ZiyuanManagerZiliao"class="ZiyuanManager_next" <?php if(in_array('ZiyuanManagerZiliao',$powerInfo['Ziyuan']['ZiyuanManager'])):?>checked="checked" <?php endif;?> >资料管理</td>
                                                            <td class="actClass"><input type="checkbox" name="ZiyuanManagerWenzhang"class="ZiyuanManager_next" <?php if(in_array('ZiyuanManagerWenzhang',$powerInfo['Ziyuan']['ZiyuanManager'])):?>checked="checked" <?php endif;?> >文章管理</td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>

                                         <table width="90%"  height="30" border="0" cellpadding=0 cellspacing=0  class="table-bordered table-invoice PeixunRoot">
                                            <tr>
                                                <td width="140px" valign='middle' class='title_td' style="display:none">
                                                    <input type="checkbox" class="title"  name="Peixun" class="title" id="Peixun"<?php if($powerInfo['Peixun']['PeixunManager']):?>checked="checked" <?php endif;?> style="opacity: 0;" >培训管理
                                                </td>
                                                <td>
                                                    <table width="90%"   cellpadding=0 cellspacing=0 class="noborder"  >
                                                        <tr>
                                                            <td height="26" valign="center"  rowspan="2" scope="col" class="Peixun_next" ><input type="checkbox" name="PeixunManager" <?php if($powerInfo['Peixun']['PeixunManager']):?>checked="checked" <?php endif;?>  >培训管理</td>
                                                            <td class="actClass"><input type="checkbox" name="PeixunManagerKechengsheji"  class="PeixunManager_next" <?php if(in_array('PeixunManagerKechengsheji',$powerInfo['Peixun']['PeixunManager'])):?>checked="checked" <?php endif;?> >网络课程设计</td>
                                                            <td class="actClass"><input type="checkbox" name="PeixunManagerXueyuandabiao"class="PeixunManager_next" <?php if(in_array('PeixunManagerXueyuandabiao',$powerInfo['Peixun']['PeixunManager'])):?>checked="checked" <?php endif;?> >学员达标台账</td>
                                                        </tr>
                                                        <tr>
                                                            <td class="actClass"><input type="checkbox" name="PeixunManagerPeixundabiao"class="PeixunManager_next" <?php if(in_array('PeixunManagerPeixundabiao',$powerInfo['Peixun']['PeixunManager'])):?>checked="checked" <?php endif;?> >培训达标台账</td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>

                                        <table width="90%"  height="30" border="0" cellpadding=0 cellspacing=0  class="table-bordered table-invoice KaoshiRoot">
                                            <tr>
                                                <td width="140px" valign='middle' class='title_td' style="display:none">
                                                    <input type="checkbox" class="title"  name="Kaoshi" class="title" id="Kaoshi"<?php if($powerInfo['Kaoshi']['KaoshiManager']):?>checked="checked" <?php endif;?> style="opacity: 0;" >考试管理
                                                </td>
                                                <td>
                                                    <table width="90%"   cellpadding=0 cellspacing=0 class="noborder"  >
                                                        <tr>
                                                            <td height="26" valign="center"  rowspan="2" scope="col" class="Kaoshi_next" >
                                                                <input type="checkbox" name="KaoshiManager" <?php if($powerInfo['Kaoshi']['KaoshiManager']):?>checked="checked" <?php endif;?>  >考试管理
                                                            </td>
                                                            <td class="actClass"><input type="checkbox" name="KaoshiManagerZhishidian"  class="KaoshiManager_next" <?php if(in_array('KaoshiManagerZhishidian',$powerInfo['Kaoshi']['KaoshiManager'])):?>checked="checked" <?php endif;?> >知识点管理</td>
                                                            <td class="actClass"><input type="checkbox" name="KaoshiManagerTixing"class="KaoshiManager_next" <?php if(in_array('KaoshiManagerTixing',$powerInfo['Kaoshi']['KaoshiManager'])):?>checked="checked" <?php endif;?> >题型管理</td>
                                                            <td class="actClass"><input type="checkbox" name="KaoshiManagerTiku"class="KaoshiManager_next" <?php if(in_array('KaoshiManagerTiku',$powerInfo['Kaoshi']['KaoshiManager'])):?>checked="checked" <?php endif;?> >题库管理</td>
                                                            <td class="actClass"><input type="checkbox" name="KaoshiManagerShijuan"class="KaoshiManager_next" <?php if(in_array('KaoshiManagerShijuan',$powerInfo['Kaoshi']['KaoshiManager'])):?>checked="checked" <?php endif;?> >试卷管理</td>
                                                        </tr>
                                                        <tr>
                                                            
                                                            <td class="actClass"><input type="checkbox" name="KaoshiManagerKaoshi"class="KaoshiManager_next" <?php if(in_array('KaoshiManagerKaoshi',$powerInfo['Kaoshi']['KaoshiManager'])):?>checked="checked" <?php endif;?> >考试安排</td>
                                                            <td class="actClass"><input type="checkbox" name="KaoshiManagerLianxi"class="KaoshiManager_next" <?php if(in_array('KaoshiManagerLianxi',$powerInfo['Kaoshi']['KaoshiManager'])):?>checked="checked" <?php endif;?> >练习安排</td>
                                                            <td class="actClass"><input type="checkbox" name="KaoshiManagerRengongfuping"class="KaoshiManager_next" <?php if(in_array('KaoshiManagerRengongfuping',$powerInfo['Kaoshi']['KaoshiManager'])):?>checked="checked" <?php endif;?> >人工复评</td>
                                                            <td class="actClass"><input type="checkbox" name="KaoshiManagerChengji"class="KaoshiManager_next" <?php if(in_array('KaoshiManagerChengji',$powerInfo['Kaoshi']['KaoshiManager'])):?>checked="checked" <?php endif;?> >成绩管理</td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>

                                        <table width="90%"  height="30" border="0" cellpadding=0 cellspacing=0  class="table-bordered table-invoice TongjiRoot">
                                            <tr>
                                                <td width="140px" valign='middle' class='title_td' style="display:none">
                                                    <input type="checkbox" class="title"  name="Tongji" class="title" id="Tongji"<?php if($powerInfo['Tongji']['TongjiManager']):?>checked="checked" <?php endif;?> style="opacity: 0;" >统计分析
                                                </td>
                                                <td>
                                                    <table width="90%"   cellpadding=0 cellspacing=0 class="noborder"  >
                                                        <tr>
                                                            <td height="26" valign="center"  rowspan="2" scope="col" class="Tongji_next" >
                                                                <input type="checkbox" name="TongjiManager" <?php if($powerInfo['Tongji']['TongjiManager']):?>checked="checked" <?php endif;?>  >统计分析
                                                            </td>
                                                            <td class="actClass"><input type="checkbox" name="TongjiManagerZhishidian"  class="TongjiManager_next" <?php if(in_array('TongjiManagerZhishidian',$powerInfo['Tongji']['TongjiManager'])):?>checked="checked" <?php endif;?> >知识点使用率统计</td>
                                                            <td class="actClass"><input type="checkbox" name="TongjiManagerTixing"class="TongjiManager_next" <?php if(in_array('TongjiManagerTixing',$powerInfo['Tongji']['TongjiManager'])):?>checked="checked" <?php endif;?> >题型试题统计</td>
                                                        </tr>
                                                        <tr>
                                                            <td class="actClass"><input type="checkbox" name="TongjiManagerBumen"class="TongjiManager_next" <?php if(in_array('TongjiManagerBumen',$powerInfo['Tongji']['TongjiManager'])):?>checked="checked" <?php endif;?> >考试按部门统计</td>
                                                            <td class="actClass"><input type="checkbox" name="TongjiManagerYonghu"class="TongjiManager_next" <?php if(in_array('TongjiManagerYonghu',$powerInfo['Tongji']['TongjiManager'])):?>checked="checked" <?php endif;?> >考试按用户统计</td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>

                                        
                                        <input type="hidden" value="" name="powerstr" id ="groupPowerstr" ><input type="hidden" value="<?php echo $groupID?>" name="gropuID"></input>
                                    </form>

                                    <table width="90%" style="margin-left: 20px;">
                                        <tr><td class="none">
                                                <input type="checkbox" class="all" >全选
                                                <input type="button" class="btn btn-success submit" value="保存">
                                        </tr></td>
                                    </table>
                
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /Page Body -->
</div>
<!-- /Page Content -->
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script src="<?php echo STATICURL; ?>js/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('.all').click(function(){
            if($(this).attr("checked")){
                $("#theForm").find("input[type='checkbox']").attr('checked','true');
            }else{
                $("#theForm").find("input[type='checkbox']").removeAttr('checked');
            }
        });

        $('.submit').click(function(){
            var rolename = $('input[name="rolename"]').val();
            if(rolename == ""){
                alert("请添加角色名");return false;
            }
            var str = getgroupPower();
            if('' != str){
                $('#groupPowerstr').val(str);
            }
            $("#theForm").submit();
        });
        $('input[type="checkbox"]').click(function(){
            var partclass = $(this).parent().attr('class');
            switch(partclass){
                case "title_td": clickTitle(this);
                    break;
                case "actClass":clcikLast(this);
                    break;
                case "none": return "";
                    break;
                default: clickCenter(this);
                    ;break;
            }
        })
        $('.bordtd-table tr>th ').css({'border-left':'1px solid #ccc','border-bottom':'1px solid #ccc'});
        $('.bordtd-table tr>td ').css({'border-left':'1px solid #ccc','border-bottom':'1px solid #ccc'});
        $('.noborder tr>td').css({'border':'none'})
    })
    function getgroupPower( ){
        var str  = "";
        var stip = "";
        $('.title_td').find('input').each(function(){
            if("checked" == $(this).attr("checked")){
                str += stip + $(this).attr('name')+":"+ find_next( $(this).attr('name') );
                stip = "|";
            }
        })
        return str;
    }
    function find_next( tip ){
        var cla = "."+tip+"_next";
        var str = ''; var stip = "";
        $(cla).find('input').each(function(){
            if( 'title' == $(this).parent().attr('name') ){
                if( "checked" == $(this).attr("checked")){
                    stip = "#";
                    str += stip + $(this).attr('name')+":"+find_next( $(this).attr('name') );
                }
            }else{
                if( "checked" == $(this).attr("checked")){
                    str += stip + $(this).attr('name')+"*"+lastgroupPower( $(this).attr('name') );
                    stip = "-";
                }
            }
        })
        return str;
    }

    function lastgroupPower( cla ){
        var str  = "";
        var stip = "";
        var clas = "."+cla+"_next";
        $(clas).each(function(){
            //控制最下级单个操作权限的设置
            if( "checked" == $(this).attr("checked")){
                str += stip + $(this).attr('name');
                stip = "%";
            }
        })
        return str;
    }

    function clickTitle(obj){
        if('checked' == $(obj).attr('checked')){
            var name = $(obj).attr('name');
            var next_class = "."+name+"_next";
            $(next_class).each(function(){
                if('title' == $(this).attr('name') ){
                    $(this).find('input[type="checkbox"]').attr("checked","true");
                    var next_class_1 = "."+$(this).find('input[type="checkbox"]').attr("name")+"_next";
                    $(next_class_1).each(function(){
                        $(this).find('input[type="checkbox"]').attr("checked","true");
                        var next_next_class =  "."+$(this).find('input[type="checkbox"]').attr("name")+"_next";
                        $(next_next_class).attr("checked","true");
                    })
                }else{
                    $(this).find('input[type="checkbox"]').attr("checked","true");
                    var next_next_class =  "."+$(this).find('input[type="checkbox"]').attr("name")+"_next";
                    $(next_next_class).attr("checked","true");
                }
            })
        }else{
            var name = $(obj).attr('name');
            var next_class = "."+name+"_next";
            $(next_class).each(function(){
                if('title' == $(this).attr('name') ){
                    $(this).find('input[type="checkbox"]').removeAttr('checked');
                    var next_class_1 = "."+$(this).find('input[type="checkbox"]').attr("name")+"_next";
                    $(next_class_1).each(function(){
                        $(this).find('input[type="checkbox"]').removeAttr('checked');
                        var next_next_class =  "."+$(this).find('input[type="checkbox"]').attr("name")+"_next";
                        $(next_next_class).removeAttr('checked');
                    })
                }else{
                    $(this).find('input[type="checkbox"]').removeAttr('checked');
                    var next_next_class =  "."+$(this).find('input[type="checkbox"]').attr("name")+"_next";
                    $(next_next_class).removeAttr('checked');
                }
            })
        }
    }

    function clickCenter(obj){
        if('checked' == $(obj).attr('checked')){
            $("input[name='"+$(obj).attr('name')+"']").attr("checked","true");
            if('title' == $(obj).parent().attr('name') ){
                var next_class = "."+$(obj).attr('name')+"_next";
                $( next_class ).each(function(){
                    $(this).find('input[type="checkbox"]').attr("checked","true");
                    $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").attr("checked","true");
                })
            }else{
                $(obj).find('input[type="checkbox"]').attr("checked","true");
                var next_next_class =  "."+$(obj).attr('name')+"_next";
                $(next_next_class).attr("checked","true");
            }
            if('HotelList' == $(obj).attr('name') || 'HotelGroupList' == $(obj).attr('name') || 'HotelByname' == $(obj).attr('name') ){
                if( 'checked' == $('input[name="HotelDetial"]').attr("checked") ){
                    $('input[name="HotelDetial"]').attr("checked",'true');
                    $('.HotelDetial_next').each(function(){
                        $(this).find('input[type="checkbox"]').attr("checked","true");
                        $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").attr("checked","true");
                    })
                }
                if( 'checked' == $('input[name="HotelGroupDetial"]').attr("checked") ){
                    $('input[name="HotelGroupDetial"]').attr("checked",'true');
                    $('.HotelGroupDetial_next').each(function(){
                        $(this).find('input[type="checkbox"]').attr("checked","true");
                        $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").attr("checked","true");
                    })
                }
                if( 'checked' == $('input[name="HotelByname"]').attr("checked") ){
                    $('input[name="HotelGroupDetial"]').attr("checked",'true');
                    $('.HotelGroupDetial_next').each(function(){
                        $(this).find('input[type="checkbox"]').attr("checked","true");
                        $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").attr("checked","true");
                    })
                }
            }
            centerCheck(obj);
        }else{
            $("input[name='"+$(obj).attr('name')+"']").removeAttr('checked');
            if('title' == $(obj).parent().attr('name') ){
                $("."+$(obj).attr('name')+"_next").each(function(){
                    $(this).find('input[type="checkbox"]').removeAttr('checked');
                    $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").removeAttr('checked');
                })
            }else{
                $('input[name="'+$(obj).attr('name')+'"]').removeAttr('checked');
                $("."+$(obj).attr('name')+"_next").removeAttr('checked');
            }
            if('HotelList' == $(obj).attr('name') || 'HotelGroupList' == $(obj).attr('name') ){
                if( 'checked' != $('input[name="HotelDetial"]').attr("checked") ){
                    $('input[name="HotelDetial"]').removeAttr('checked');
                    $('.HotelDetial_next').each(function(){
                        $(this).find('input[type="checkbox"]').removeAttr('checked');
                        $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").removeAttr('checked');
                    })
                }
                if( 'checked' != $('input[name="HotelGroupDetial"]').attr("checked") ){
                    $('input[name="HotelGroupDetial"]').removeAttr('checked');
                    $('.HotelGroupDetial_next').each(function(){
                        $(this).find('input[type="checkbox"]').removeAttr('checked');
                        $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").removeAttr('checked');
                    })
                }
            }
            centerUnCheck(obj);
        }
    }

    function centerCheck(obj){
        var par = $(obj).parent().attr('class');
        par = par.replace('_next','');
        var root = find_root( $(obj).attr('name') );
        if( root == par ){
            $('input[name="'+root+'"]').attr('checked','true');
            $('input[name="'+$(obj).attr('name')+'"]').each(function(){
                if( undefined != $(this).attr('class') ){
                    var par2 = $(this).attr('class');
                    par2 = par2.replace('_next','');
                    $('input[name="'+par2+'"]').attr('checked','true');
                }
            })
        }else{
            $('input[name="'+root+'"]').attr('checked','true');
            $('input[name="'+par+'"]').attr('checked','true');
            $('input[name="'+par+'"]').each(function(){
                if( undefined != $(this).attr('class') ){
                    var par2 = $(this).attr('class');
                    par2 = par2.replace('_next','');
                    $('input[name="'+par2+'"]').attr('checked','true');
                }
            })
        }

    }

    function centerUnCheck(obj){
        var par = $(obj).parent().attr('class');
        par = par.replace('_next','');
        var root = find_root( $(obj).attr('name') );
        if( 'HotelDetial' == $(obj).attr('name') ||  'HotelGroupDetial' == $(obj).attr('name') ){
            $("input[name='"+$(obj).attr('name')+"']").each(function(){
                $(this).removeAttr('checked');
                if(undefined != $(this).attr('class')){
                    var state2 = true;
                    $('.'+$(this).attr('class')).each(function(){
                        if("checked" == $(this).attr("checked") ){
                            state2 = false;
                        }
                    })
                }
                if( state2 ){
                    var ppar = $(this).attr('class');
                    ppar = ppar.replace('_next','');
                    $("input[name='"+ppar+"']").removeAttr('checked');
                }
            })
        }
        var state = true;
        $("."+par+"_next").each(function(){
            if( "checked" == $(this).find('input[type="checkbox"]').attr("checked")){
                state = false;
            }
            $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").each(function(){
                if( "checked" == $(this).attr("checked") ){
                    state = false;
                }
            });
        })
        if( state ){
            $("input[name='"+par+"']").removeAttr('checked');
            var state2 = true;
            $('.'+root+'_next').each(function(){
                if( "checked" == $(this).find('input[type="checkbox"]').attr("checked")){
                    state2 = false;
                }
            })
            if(state2){
                $("input[name='"+root+"']").removeAttr('checked');
            }
        }
    }

    //获取跟节点
    function find_root(cla){
        var parent = cla.replace("_next",'');
        if( 'title_td' == $("input[name='"+parent+"']").parent().attr('class')){
        }else{
            if('actClass' == $("input[name='"+parent+"']").parent().attr('class') ){
                parent = find_root($("input[name='"+parent+"']").attr('class'));
            }else{
                parent = find_root($("input[name='"+parent+"']").parent().attr('class'));
            }
        }
        return parent;
    }

    function clcikLast(obj){
        if('checked' == $(obj).attr('checked')){
            var p1 = $(obj).attr('class');
            p1 = p1.replace('_next','');
            $("input[name='"+p1+"']").attr("checked","true");
            var p2 = $("input[name='"+p1+"']").parent().attr("class");
            p2 = p2.replace('_next','');
            $("input[name='"+p2+"']").attr("checked","true");
            $("input[name='"+p2+"']").each(function(){
                if( 'title' == $(this).parent().attr('name') ){
                    var p3 = $(this).parent().attr("class");
                    p3 = p3.replace('_next','');
                    $("input[name='"+p3+"']").attr("checked","true");
                }else{
                    var p3 = $(this).attr("class");
                    p3 = p3.replace('_next','');
                    $("input[name='"+p3+"']").attr("checked","true");
                }
            })
            var  nowname = $(obj).attr('name');
            if( 'HotelDetial' == nowname || 'HotelGroupDetial' == nowname ){
                $("input[name='"+nowname+"']").attr('checked','true');
                $("."+nowname+"_next").each(function(){
                    $(this).find('input[type="checkbox"]').attr("checked","true");
                    $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").attr("checked","true");
                })
            }

        }else{
            var  nowname = $(obj).attr('name');
            if( 'HotelDetial' == nowname || 'HotelGroupDetial' == nowname ){
                $("input[name='"+nowname+"']").removeAttr("checked");
                $("."+nowname+"_next").each(function(){
                    $(this).find('input[type="checkbox"]').removeAttr('checked');
                    $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").removeAttr('checked');
                })
            }
            var state = true;
            $("."+$(obj).attr('class')).each(function(){
                if( "checked" == $(this).attr('checked') ){
                    state = false;
                }
            })
            if(state){
                var p1 = $(obj).attr('class');
                p1 = p1.replace('_next','');
                $("input[name='"+p1+"']").removeAttr("checked");
                var par = $("input[name='"+p1+"']").parent().attr('class');
                par = par.replace('_next','');
                var root = find_root( $("input[name='"+p1+"']").parent().attr('class') );
                var state2 = true;
                if( par == root ){
                    $('.'+root+'_next').each(function(){
                        if( "checked" == $(this).find('input[type="checkbox"]').attr("checked")){
                            state2 = false;
                        }
                        $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").each(function(){
                            if( "checked" == $(this).attr("checked") ){
                                state2 = false;
                            }
                        });
                    })
                    if( state2 ){
                        $("input[name='"+root+"']").removeAttr("checked");
                    }
                }else{
                    $('.'+par+'_next').each(function(){
                        if( "checked" == $(this).find('input[type="checkbox"]').attr("checked")){
                            state2 = false;
                        }
                        $("."+$(this).find('input[type="checkbox"]').attr('name')+"_next").each(function(){
                            if( "checked" == $(this).attr("checked") ){
                                state2 = false;
                            }
                        });
                    })
                    if( state2 ){
                        $("input[name='"+par+"']").each(function(){
                            if( undefined  == $(this).attr('class') ){
                                $(this).removeAttr("checked");
                            }else{
                                $(this).removeAttr("checked");
                                var state5 = true;
                                $('.'+$(this).attr('class')).each(function(){
                                    if("checked" == $(this).attr("checked")){
                                        state5 = false;
                                    }
                                })
                                if(state5){
                                    var p5 = $(this).attr("class");
                                    p5 = p5.replace("_next","");
                                    $("input[name='"+p5+"']").removeAttr("checked");
                                }
                            }
                        })
                        var stat6 = true;
                        $("."+root+"_next").each(function(){
                            if("checked" == $(this).attr("checked")){
                                stat6 = false;
                            }
                        })
                        if(stat6){
                            $("input[name='"+root+"']").removeAttr("checked");
                        }
                    }
                }
                //var par  =
            }
        }
    }
</script>





